package com.algo.pmtong;

import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;

public class AddTAUV{
	public static void main(String[] args) throws IOException{
		//FSDataInputStream fsin = FileSystem.get(new Configuration()).open(new Path(args[0]));
		//BufferedReader in = new BufferedReader(new InputStreamReader(fsin));
		PathFilesReader in = new PathFilesReader(new Path(args[0]));
		
		double[][] sex = new double[2][10];
		double[][] age = new double[8][10];
		double[][] edu = new double[4][10];
		double[][] salary = new double[5][10];
		
		double[][] usex = new double[2][10];
                double[][] uage = new double[8][10];
                double[][] uedu = new double[4][10];
                double[][] usalary = new double[5][10];

		String line;
		while((line = in.readLine()) != null){
			String[] items = line.split("[,\\t]");
			if(items.length < 7 || !items[0].equals(args[1]))
				continue;
			int label1 = Integer.parseInt(items[1]);
			int label2 = Integer.parseInt(items[2]);
			int label3 = Integer.parseInt(items[3]);
			int label4 = Integer.parseInt(items[4]);
			int nPlus;
			double uv;
			if(items.length == 7){
				nPlus = Integer.parseInt(items[5].substring(0, items[5].length()-1)) - 1;
				uv = Double.parseDouble(items[6]);
				sex[label1][nPlus] += uv;
				age[label2][nPlus] += uv;
				edu[label3][nPlus] += uv;
				salary[label4][nPlus] += uv;
			}else if(items.length == 8 && items[5].equals(args[2])){
				nPlus = Integer.parseInt(items[6].substring(0, items[6].length()-1)) - 1;
				uv = Double.parseDouble(items[7]);
                                usex[label1][nPlus] += uv;
                                uage[label2][nPlus] += uv;
                                uedu[label3][nPlus] += uv;
                                usalary[label4][nPlus] += uv;
			}
		}
		for(int i = 0; i < 2; i++)
			for(int j = 0; j < 10; j++){
				System.out.format("%10s", i + ":" + (j+1) + "+,");
				System.out.format("%10s", sex[i][j] + ",");
				System.out.format("%10s", usex[i][j] + ",");
				System.out.println();
			}
		for(int i = 0; i < 8; i++)
			for(int j = 0; j < 10; j++){
                                System.out.format("%10s", i + ":" + (j+1) + "+,");
                                System.out.format("%10s", age[i][j] + ",");
                                System.out.format("%10s", uage[i][j] + ",");
                                System.out.println();
                        }
		for(int i = 0; i < 4; i++)
			for(int j = 0; j < 10; j++){
                                System.out.format("%10s", i + ":" + (j+1) + "+,");
                                System.out.format("%10s", edu[i][j] + ",");
                                System.out.format("%10s", uedu[i][j] + ",");
                                System.out.println();
                        }

		for(int i = 0; i < 5; i++)
			for(int j = 0; j < 10; j++){
                                System.out.format("%10s", i + ":" + (j+1) + "+,");
                                System.out.format("%10s", salary[i][j] + ",");
                                System.out.format("%10s", usalary[i][j] + ",");
                                System.out.println();
                        }
		
	}
}







